<?php if(!defined('IN_PISCES')){exit('Access Denied.');}?>
<script language="javascript" src="{$this->data['baseurl']}js/jquery/jquery.js"></script>
<script language="javascript" src="{$this->data['baseurl']}js/jquery/form.js"></script>
<script language="javascript" src="{$this->data['baseurl']}js/utils.js"></script>
<script type="text/javascript">
var successFun=function(res){
if(res.code==200){
	document.location	= res.data.forward;
}else{
	alert('出错了，请重新尝试！');
}
}
function beforeSend(){
	if(!checkMoney()){
		return false;
	}
	//$('#btnAjaxSubmit').attr('disabled',true);
}

function checkMoney(){
	var money		= parseInt($('#money').val());
	var minMoney	= parseInt($('#hdMinMoney').val());
	var totalMoney	= parseInt($('#hdTotalMoney').val());
	if(money>totalMoney){
		$('#money_info').html('返现金额不能超过可返现金额');
		return false;
	}
	if(money<minMoney){
		$('#money_info').html('返现金额不能少于最小返现金额');
		return false;
	}
	return true;
}
</script>
<div class="returnmenu"> 
<h2>申请返现</h2>
</div>
<div class="credit clear">
<div class="sect">
{if $this->data['return_setting']['rate']<=0}
<p class="tips">系统不支持返现</p> 
{else}
<h3 class="title">您当前的可返现金额是 <strong>{$this->data['info']['money']}</strong> 元</h3>
<h3 class="title">每次最少返现 <strong>{$this->data['return_setting']['return_min']}</strong> 元</h3>
{if $this->data['return_setting']['return_min']>$this->data['info']['money']}
<p class="tips">您的可返现金额少于最小返现金额<strong>{$this->data['return_setting']['return_min']}</strong>元，暂时无法申请返现</p> 
{else}
<form id="form" action="{url('Return','SaveEdit')}" method="post">
<div class="field clear"> 
<label for="money">返现金额</label> 
<input type="text" size="30" name="money" id="money" class="f-input" value="{$this->data['info']['money']}" /> 
<span class="hint" id="money_info" etype="error_info"></span> 
</div>
<input type="hidden" id="hdMinMoney" value="{$this->data['return_setting']['return_min']}" />
<input type="hidden" id="hdTotalMoney" value="{$this->data['info']['money']}" />
<input type="submit" value="好了，提交" name="commit" id="btnAjaxSubmit" class="formbutton"/> 
</form>

{/if}
{/if}
</div>
</div>
<script type="text/javascript">
var updateOptions	= {dataType:'json',error:doError,beforeSend:beforeSend,success:doSuccess}
$('#form').ajaxForm(updateOptions); 
</script>